<?php
header("Access-Control-Allow-Origin:*");
//返回房间的所有文件
require_once '../../dz_framework/init.php';
require_once SITE_ROOT.'openapi/public_class_core.php';
$roomid = $_GET['roomid'] ? $_GET['roomid'] : '0';
$roomid = intval($_GET['roomid']);
if (empty($roomid)) {
    errmsg('-1', '缺失房间ID');
}
$hour_info = DB::fetch_first("select * from ".DB::table('course_hour')." where ch_id = '$roomid' LIMIT 1");
if (empty($hour_info['ch_files'])) {
    errmsg('-1', '该房间没有文件');
} else {
	$file_ids = explode(',', $hour_info['ch_files']);
	$file_list = array();
	xmlheader();
    echo "<files_list>";
    foreach ($file_ids as $value) {
        $file_info = DB::fetch_first("SELECT fs_id,fs_name ,fs_extension ,fs_store_path ,fs_real_name FROM ".DB::table('file_source')." WHERE fs_id='$value' LIMIT 1");
        echo "<file>";
        echo "<file_id>".$file_info['fs_id']."</file_id>";
        echo "<file_name>".str_replace(array('if','IF','IF','iF','&'),'',$file_info['fs_name'])."</file_name>";
        echo "<file_store_path>/data/attachment/filestores/".$file_info['fs_store_path'].'/'.$file_info['fs_real_name'].'.'.$file_info['fs_extension']."</file_store_path>";
        echo "</file>";
    }
    echo "</files_list>";
    xmlfooter();      
}